# installBullockPackage.R

# Part of the replication archive for 
#
#   Bullock, John G. 2020. "Education and Attitudes toward Redistribution in
#   the United States." British Journal of Political Science 50.


# Many of the files in the replication archive require the "Bullock" package,
# which is a collection of small utility functions. The file installs the 
# package into a local library.


education_BJPS_lib <- 'packageLibrary' 
if (! 'Bullock' %in% installed.packages(lib.loc = education_BJPS_lib)[, 'Package']) {

  if (!dir.exists(education_BJPS_lib)) dir.create(education_BJPS_lib)

  if (Sys.info()['sysname'] == 'Windows') {
    install.packages(
      pkgs    = 'Bullock_1.19_source/Bullock_1.19.zip',
      repos  = NULL,
      lib     = normalizePath(education_BJPS_lib),
      verbose = TRUE)
  } else {
    install.packages(
      pkgs    = 'Bullock_1.19_source/Bullock_1.19.tar.gz', 
      repos   = NULL, 
      type    = "source", 
      lib     = normalizePath(education_BJPS_lib),
      verbose = TRUE)
  }
}

